home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / DVD / DVDSample / stringutil.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  7.5 KB  |  241 lines

  1. //------------------------------------------------------------------------------
  2. // File: StringUtil.cpp
  3. //
  4. // Desc: This file contains several enum to string conversion functions
  5. //       which are used throughout the rest of the program.
  6. //
  7. // Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10. #include <dshow.h>
  11. #include <TCHAR.H>
  12. #include "StringUtil.h"
  13.  
  14.  
  15.  
  16.  
  17. //------------------------------------------------------------------------------
  18. // Macros
  19. //------------------------------------------------------------------------------
  20.  
  21. // this will create a case statement from the name of the enum type
  22. #define ENUM_CASE( x )    case x: return TEXT(#x)
  23.  
  24.  
  25.  
  26.  
  27. //------------------------------------------------------------------------------
  28. // Name: AsStr()
  29. // Desc: This overloaded function converts enumerationd into human-readable 
  30. //       text.  In most cases, it utilizes the ENUM_CASE macro to create
  31. //       generic strings out of the enumerated types.  If you want more user-friendly
  32. //       strings, use the form found in the DVD_TextStringType function.
  33. //------------------------------------------------------------------------------
  34.  
  35. const TCHAR* AsStr( DVD_TextStringType IDCD )
  36. // Turn an Enumerated TextStringType into a human-readable string
  37. {
  38.     switch( IDCD ) {
  39.     case DVD_Struct_Volume:            return TEXT("Struct_Volume");
  40.     case DVD_Struct_Title:            return TEXT("Struct_Title");
  41.     case DVD_Struct_ParentalID:        return TEXT("Struct_ParentalID");
  42.     case DVD_Struct_PartOfTitle:    return TEXT("Struct_Chapter");
  43.     case DVD_Struct_Cell:           return TEXT("Struct_Cell");
  44.     case DVD_Stream_Audio:          return TEXT("Stream_Audio");
  45.     case DVD_Stream_Subpicture:        return TEXT("Stream_Sub-picture");
  46.     case DVD_Stream_Angle:            return TEXT("Stream_Angle");
  47.     case DVD_Channel_Audio:            return TEXT("Audio Channel");
  48.     case DVD_General_Name:          return TEXT("General_name");
  49.     case DVD_General_Comments:      return TEXT("General_comments");
  50.     case DVD_Title_Series:          return TEXT("Title_Series");
  51.     case DVD_Title_Movie:           return TEXT("Title_Movie");
  52.     case DVD_Title_Video:           return TEXT("Title_Video");
  53.     case DVD_Title_Album:           return TEXT("Title_Album");
  54.     case DVD_Title_Song:            return TEXT("Title_Song");
  55.     case DVD_Title_Other:           return TEXT("Title_Other");
  56.     case DVD_Title_Sub_Series:      return TEXT("Title_Sub_Series");
  57.     case DVD_Title_Sub_Movie:       return TEXT("Title_Sub_Movie");
  58.     case DVD_Title_Sub_Video:       return TEXT("Title_Sub_Video");
  59.     case DVD_Title_Sub_Album:       return TEXT("Title_Sub_Album");
  60.     case DVD_Title_Sub_Song:        return TEXT("Title_Sub_Song");
  61.     case DVD_Title_Sub_Other:       return TEXT("Title_Sub_Other");
  62.     case DVD_Title_Orig_Series:     return TEXT("Title_Orig_Series");
  63.     case DVD_Title_Orig_Movie:      return TEXT("Title_Orig_Movie");
  64.     case DVD_Title_Orig_Video:      return TEXT("Title_Orig_Video");
  65.     case DVD_Title_Orig_Album:      return TEXT("Title_Orig_Album");
  66.     case DVD_Title_Orig_Song:       return TEXT("Title_Orig_Song");
  67.     case DVD_Title_Orig_Other:      return TEXT("Title_Orig_Other");
  68.     default:                        return TEXT("Unknown");
  69.     }
  70. }
  71.  
  72. const TCHAR* AsStr( DVD_AUDIO_LANG_EXT ext )
  73. {
  74.     switch( ext )
  75.     {
  76.     ENUM_CASE( DVD_AUD_EXT_NotSpecified );
  77.     ENUM_CASE( DVD_AUD_EXT_Captions );
  78.     ENUM_CASE( DVD_AUD_EXT_VisuallyImpaired );
  79.     ENUM_CASE( DVD_AUD_EXT_DirectorComments1 );
  80.     ENUM_CASE( DVD_AUD_EXT_DirectorComments2 );
  81.     default:
  82.         return TEXT("UNKNOWN");
  83.     }
  84. }
  85.  
  86. const TCHAR* AsStr( DVD_SUBPICTURE_LANG_EXT ext )
  87. {
  88.     switch( ext )
  89.     {
  90.     ENUM_CASE( DVD_SP_EXT_NotSpecified );
  91.     ENUM_CASE( DVD_SP_EXT_Caption_Normal );
  92.     ENUM_CASE( DVD_SP_EXT_Caption_Big );
  93.     ENUM_CASE( DVD_SP_EXT_Caption_Children );
  94.     ENUM_CASE( DVD_SP_EXT_CC_Normal );
  95.     ENUM_CASE( DVD_SP_EXT_CC_Big );
  96.     ENUM_CASE( DVD_SP_EXT_CC_Children );
  97.     ENUM_CASE( DVD_SP_EXT_Forced );
  98.     ENUM_CASE( DVD_SP_EXT_DirectorComments_Normal );
  99.     ENUM_CASE( DVD_SP_EXT_DirectorComments_Big );
  100.     ENUM_CASE( DVD_SP_EXT_DirectorComments_Children );
  101.     default:
  102.         return TEXT("UNKNOWN");
  103.     }
  104. }
  105.  
  106. const TCHAR* AsStr( DVD_AUDIO_APPMODE ext )
  107. {
  108.     switch( ext )
  109.     {
  110.     ENUM_CASE( DVD_AudioMode_None );
  111.     ENUM_CASE( DVD_AudioMode_Karaoke );
  112.     ENUM_CASE( DVD_AudioMode_Surround );
  113.     ENUM_CASE( DVD_AudioMode_Other );
  114.     default: 
  115.         return TEXT("UNKNOWN");
  116.     }
  117. }
  118.  
  119. const TCHAR* AsStr( DVD_AUDIO_FORMAT  ext )
  120. {
  121.     switch( ext )
  122.     {
  123.     ENUM_CASE( DVD_AudioFormat_AC3 );
  124.     ENUM_CASE( DVD_AudioFormat_MPEG1 );
  125.     ENUM_CASE( DVD_AudioFormat_MPEG1_DRC );
  126.     ENUM_CASE( DVD_AudioFormat_MPEG2 );
  127.     ENUM_CASE( DVD_AudioFormat_MPEG2_DRC );
  128.     ENUM_CASE( DVD_AudioFormat_LPCM );
  129.     ENUM_CASE( DVD_AudioFormat_DTS );
  130.     ENUM_CASE( DVD_AudioFormat_SDDS );
  131.     ENUM_CASE( DVD_AudioFormat_Other );
  132.     default:
  133.         return TEXT("UNKNOWN");
  134.     }
  135. }
  136.  
  137. const TCHAR* AsStr( DVD_KARAOKE_ASSIGNMENT ext )
  138. {
  139.     switch( ext )
  140.     {
  141.         ENUM_CASE( DVD_Assignment_reserved0 );
  142.         ENUM_CASE( DVD_Assignment_reserved1 );
  143.         ENUM_CASE( DVD_Assignment_LR  );
  144.         ENUM_CASE( DVD_Assignment_LRM );
  145.         ENUM_CASE( DVD_Assignment_LR1 );
  146.         ENUM_CASE( DVD_Assignment_LRM1);
  147.         ENUM_CASE( DVD_Assignment_LR12);
  148.         ENUM_CASE( DVD_Assignment_LRM12);
  149.     default:
  150.         return TEXT("UNKNOWN");
  151.     }
  152. }
  153.  
  154. const TCHAR* AsStr( DVD_SUBPICTURE_TYPE type )
  155. {
  156.     switch( type )
  157.     {
  158.         ENUM_CASE( DVD_SPType_NotSpecified );
  159.         ENUM_CASE( DVD_SPType_Language );
  160.         ENUM_CASE( DVD_SPType_Other );
  161.     default:
  162.         return TEXT("UNKNOWN");
  163.     }
  164. }
  165.  
  166. const TCHAR* AsStr( DVD_SUBPICTURE_CODING type )
  167. {
  168.     switch( type )
  169.     {
  170.         ENUM_CASE( DVD_SPCoding_RunLength );
  171.         ENUM_CASE( DVD_SPCoding_Extended );
  172.         ENUM_CASE( DVD_SPCoding_Other );
  173.     default:
  174.         return TEXT("UNKNOWN");
  175.     }
  176. }
  177.  
  178. const TCHAR* AsStr( DVD_VIDEO_COMPRESSION type )
  179. {
  180.     switch( type )
  181.     {
  182.         ENUM_CASE( DVD_VideoCompression_Other );
  183.         ENUM_CASE( DVD_VideoCompression_MPEG1 );
  184.         ENUM_CASE( DVD_VideoCompression_MPEG2 );
  185.     default:
  186.         return TEXT("UNKNOWN");
  187.     }
  188. }
  189.  
  190. const TCHAR* AsStr( bool b )
  191. {
  192.     if( b )
  193.         return TEXT("true");
  194.     else
  195.         return TEXT("false");
  196. }
  197.  
  198. const TCHAR* AsStr( BOOL b )
  199. {
  200.     if( b )
  201.         return TEXT("true");
  202.     else
  203.         return TEXT("false");
  204. }
  205.  
  206.  
  207. //------------------------------------------------------------------------------
  208. // Name: KaraokeAsStr()
  209. // Desc: This method returns the text name of the contents of a karaoke channel.
  210. //       a function header should look like.  This function is set apart from 
  211. //       the other AsStr functions because the DVD_KARAOKE_CONTENTS type is passed
  212. //       as a word, not an enum.
  213. //
  214. //       A single channel can contain several of these content types.  Here just 
  215. //       the first is returned. 
  216. //------------------------------------------------------------------------------
  217. const TCHAR* KaraokeAsStr (WORD type)
  218. {
  219.     if (type & DVD_Karaoke_GuideVocal1)
  220.         return TEXT("GuideVocal1");
  221.     if (type & DVD_Karaoke_GuideVocal2)
  222.         return TEXT("GuideVocal2");
  223.     if (type & DVD_Karaoke_GuideMelody1)
  224.         return TEXT("GuideMelody1");
  225.     if (type & DVD_Karaoke_GuideMelody2)
  226.         return TEXT("GuideMelody2");
  227.     if (type & DVD_Karaoke_GuideMelodyA)
  228.         return TEXT("GuideMelodyA");
  229.     if (type & DVD_Karaoke_GuideMelodyB)
  230.         return TEXT("GuideMelodyB");
  231.     if (type & DVD_Karaoke_SoundEffectA)
  232.         return TEXT("SoundEffectA");
  233.     if (type & DVD_Karaoke_SoundEffectB)
  234.         return TEXT("SoundEffectB");
  235.     else return TEXT("Unknown");
  236. }
  237.  
  238.  
  239.  
  240.  
  241.